package com.global.base;

import java.util.List;

import org.apache.commons.lang.StringUtils;

/**
 * 将异常Exception的StackTrace转换为字符串
 * @author zly601436
 *
 */
public final class ExceptionUtil {

	private ExceptionUtil() {
	}

	/**
	 * 获取转换后的字符串
	 * @param e 参考 {@linkplain Exception}
	 * @return String
	 */
	public static String getString(Exception e) {
		String message = "";
		StackTraceElement[] stackTrace = e.getStackTrace();
		if (stackTrace != null) {
			message = e.getClass().getName() + ": " + e.getMessage();
			for (int i = 0; i < stackTrace.length; i++) {
				message = message + "\n" + stackTrace[i].toString();
			}
		}

		return message;
	}
}
